package com.woorigil.android.sample.domain;

public enum ProviderCode {
	CP {
		@Override
		public String getDisplay() {
			return "쿠팡";
		}
		@Override
		public String getAddress() {
			return "15777011";
		}
		@Override
		public int getPosition() {
			return 0;
		}
	},
	TM {
		@Override
		public String getDisplay() {
			return "티몬";
		}
		@Override
		public String getAddress() {
			return "15446240";
		}
		@Override
		public int getPosition() {
			return 1;
		}
	},
	WM {
		@Override
		public String getDisplay() {
			return "위메프";
		}
		@Override
		public String getAddress() {
			return "15884763";
		}
		@Override
		public int getPosition() {
			return 2;
		}
	}, 
	OC {
		@Override
		public String getDisplay() {
			return "오클락";
		}
		@Override
		public String getAddress() {
			return "";
		}
		@Override
		public int getPosition() {
			return 3;
		}
	},
	GP {
		@Override
		public String getDisplay() {
			return "그루폰";
		}
		@Override
		public String getAddress() {
			return "";
		}
		@Override
		public int getPosition() {
			return 4;
		}
	};
	
	public static ProviderCode getProviderCode(String address) {
		for (ProviderCode each : ProviderCode.values()) {
			if (each.getAddress().equals(address)) {
				return each;
			}
		}
		return null;
	}
	
	abstract public String getDisplay();
	abstract public String getAddress();
	abstract public int getPosition();

	public static ProviderCode getProviderCode(int position) {
		for (ProviderCode providerCode : ProviderCode.values()) {
			if (providerCode.getPosition() == position) {
				return providerCode;
			}
		}
		return ProviderCode.CP;
	}
}